package com.topnav.mc.admin.view.user;

import com.baomidou.mybatisplus.annotation.TableName;
import com.topnav.mc.admin.entity.User;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;

@Data
@TableName("mc_user_view")
@Slf4j
public class UserView {
    private Long id;
    private String note;
    private Date createTime;
    private Date updateTime;
    private String createBy;
    private String updateBy;

    private String loginName;
    private String password;
    private String code;
    private String name;

    private Long orgId;
    /** 1 民警 2辅警*/
    private Integer type;
    /** 启用/禁用 */
    private Boolean enabled;
    /** 登录单位，登录的时候是哪个机构的权限，默认是所属单位 */
    private Long loginOrgId;

/*    public Boolean getEnabled(){
        return this.enabled;
    }*/

    public User assignTo(User dest){
        try{

            if (dest == null){
                dest = new User();
            }
            dest.setId(this.getId());
            dest.setNote(this.getNote());
            dest.setCreateTime(this.getCreateTime());
            dest.setUpdateTime(this.getUpdateTime());

            dest.setLoginName(this.getLoginName());
            dest.setCode(this.getCode());
            dest.setName(this.getName());
            dest.setType(this.getType());
            dest.setOrgId(this.getOrgId());
            dest.setPassword(this.getPassword());
            dest.setType(this.getType());
            dest.setEnabled(this.getEnabled());
            dest.setLoginOrgId(this.getLoginOrgId());
            return dest;
        }catch(Exception e){
            log.error(">>>>>>> UserView=>User:{} ",e);
        }
        return null;
    }
    public void assign(User source){
        try{
            this.setId(source.getId());
            this.setNote(source.getNote());
            this.setCreateTime(source.getCreateTime());
            this.setUpdateTime(source.getUpdateTime());

            this.setCode(source.getCode());
            this.setName(source.getName());
            this.setType(source.getType());
            this.setOrgId(source.getOrgId());

            this.setLoginName(source.getLoginName());
            this.setType(source.getType());
            this.setPassword(source.getPassword());
            this.setEnabled(source.getEnabled());
            this.setLoginOrgId(source.getLoginOrgId());
        }catch(Exception e){
            log.error(">>>>>>> User=>UserView:{} ",e);
        }
    }
}
